﻿using System;
using System.Configuration;
using System.Collections.Generic;
using StockTrader.DAL.IDAL;
using StockTrader.DAL.Factory;
using StockTrader.BusinessService.DataContract;
using StockTrader.FrontEnd.DataContract;
using System.Data;
using System.Reflection;

namespace StockTrader.FrontEnd.MarketSummary
{
    public class DALclient
    {
        IDailySummary dalSummary;

        public void InsertDailySummary(DateTime transdate, string symbol, int open, int high, int low, int close, float average, int total, int p1, long p1value, int p2, long p2value, int p3, long p3value, int buyorder, int sellorder, int buycount, int sellcount, int pt, int ptvalue, long listing, long inmarket, float eps, float adjustedeps, int benefit, float foreignown, float stateown, string market)
        {
            dalSummary = StockTrader.DAL.Factory.DailySummaryFactory.Create(ConfigurationManager.AppSettings["DbType"]);
            try
            {
                dalSummary.Open(ConfigurationManager.AppSettings["SQLserverCnnStr"]);
                dalSummary.InsertDailySummary(transdate, symbol, open, high, low, close, average, total, p1, p1value, p2, p2value, p3, p3value, buyorder, sellorder, buycount, sellcount, pt, ptvalue, listing, inmarket, eps, adjustedeps, benefit, foreignown, stateown, market);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSummary.Close();
            }

        }
        public void InsertDailyForeignTrade(DateTime transdate, string symbol, int buy, long buyvalue, int sell, long sellvalue, int p1buy, int p2buy, int p3buy, int p1sell, int p2sell, int p3sell, int ptbuy, long ptbuyvalue, int ptsell, long ptsellvalue, long room, long remain)
        {
            dalSummary = StockTrader.DAL.Factory.DailySummaryFactory.Create(ConfigurationManager.AppSettings["DbType"]);
            try
            {
                dalSummary.Open(ConfigurationManager.AppSettings["SQLserverCnnStr"]);
                dalSummary.InsertDailyForeignTrade(transdate, symbol, buy, buyvalue, sell, sellvalue, p1buy, p2buy, p3buy, p1sell, p2sell, p3sell, ptbuy, ptbuyvalue, ptsell, ptsellvalue, room, remain);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSummary.Close();
            }

        }
        public void InsertDailyFundTrade(DateTime transdate, string symbol, string side, long register, int inday, float indayRatio, int accumulate, float accumulateRatio, int remain, float remainRatio, DateTime registerdate)
        {
            dalSummary = StockTrader.DAL.Factory.DailySummaryFactory.Create(ConfigurationManager.AppSettings["DbType"]);
            try
            {
                dalSummary.Open(ConfigurationManager.AppSettings["SQLserverCnnStr"]);
                dalSummary.InsertDailyFundTrade( transdate,  symbol,  side, register, inday,  indayRatio,   accumulate,  accumulateRatio,  remain,  remainRatio,  registerdate);
            }
            catch
            {
                throw;
            }
            finally
            {
                dalSummary.Close();
            }

        }

    }
}
